package day05.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/25
 * 1."2014-5-25"到"2012-12-28"中间有多少天？
 */
public class Test1 {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        String str1= "2014-5-25";
        String str2 = "2012-12-28";
        Date date1 = sdf.parse(str1);
        Date date2 = sdf.parse(str2);
        long time = date1.getTime() - date2.getTime();

        long day= time / (1000 * 60 * 60 * 24);
        // 输出结果
        System.out.println("从 " + str1+ " 到 " + str2 + " 中间有 " + day + " 天");
    }
}
